package com.jy.wms.controller;

import com.jy.wms.common.SetStatus;
import com.jy.wms.common.base.*;
import com.jy.wms.pojo.WmsArtificialReplenishmentDetailed;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.jy.wms.pojo.WmsOrderRepairDetailed;
import com.jy.wms.service.WmsOrderRepairDetailedService;
import javax.servlet.http.HttpSession;
import com.github.pagehelper.Page;

import java.util.List;
import com.jy.wms.common.UUIDUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @ClassName: WmsOrderRepairDetailedController
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @Author LH
 * @Date Mon Nov 13 09:23:23 GMT+08:00 2017
 */
@RestController
@RequestMapping("/wmsorderrepairdetailed")
@Api(value = "/wmsorderrepairdetailed", description = "关于订单驱动补货明细操作")
public class  WmsOrderRepairDetailedController extends BaseController<WmsOrderRepairDetailedService,WmsOrderRepairDetailed> {
/*
    @PostMapping(value = {"list", ""})
    @ApiOperation(value = "查询信息",response = JSONObject.class, notes = "查询信息")
    public @ResponseBody ResultPage<WmsOrderRepairDetailed> getWmsOrderRepairDetailed(@RequestBody WmsOrderRepairDetailed entity,HttpSession session) {
        Page<WmsOrderRepairDetailed> list= baseService.baseSelectPage(entity);
            return renderPage(list);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除信息",response = JSONObject.class, notes = "删除信息")
    public @ResponseBody JsonResult deleteWmsOrderRepairDetailed(@RequestBody List<String> ids) {
        Integer flag=baseService.baseDeleteBathPrimaryKeys(ids);
        return renderSuccess("删除成功");
    }

    @PostMapping(value = "add")
    @ApiOperation(value = "新增信息",response = JSONObject.class, notes = "新增信息")
    public @ResponseBody JsonResult addWmsOrderRepairDetailed(@RequestBody WmsOrderRepairDetailed entity) {
        entity.setId(UUIDUtils.uuid());
        baseService.baseInsert(entity);
        return renderSuccess("添加成功");
    }

    @GetMapping(value = "getWmsOrderRepairDetailed/{id}")
    @ApiOperation(value = "查看单个信息",response = JSONObject.class, notes = "GET查看单个信息")
    public @ResponseBody WmsOrderRepairDetailed getWmsOrderRepairDetailedById(@PathVariable("id") String id) {
        WmsOrderRepairDetailed entity=baseService.baseSelectByPrimaryKey(id);
        return entity;
    }*/


    @PostMapping(value = "edit")
    @ApiOperation(value = "编辑信息",response = JSONObject.class, notes = "编辑时查找明细集合,id:补货明细id")
    public @ResponseBody JSONObject editWmsArtificialReplenishmentDetailed(@RequestBody WmsOrderRepairDetailed entity) {
        try {
            Integer flag=baseService.baseUpdateByPrimaryKeySelective(entity);
            return SetStatus.setFunctionType(ReturnType.messageType_top.getType(), ReturnType.success.toString(), "补货单明细修改成功", "", JSONObject.fromObject(entity).toString());
        } catch (SucessException e) {
            e.printStackTrace();
            return SetStatus.setFunctionType(ReturnType.messageType_top.getType(), ReturnType.success.toString(), "补货单明细修改成功", "", JSONObject.fromObject(entity).toString());
        } catch (ServiceException e) {
            e.printStackTrace();
            return SetStatus.setFunctionType(ReturnType.messageType_right.getType(), ReturnType.error.toString(), "补货单明细修改失败", e.getMessage(), "");
        }catch (Exception e) {
            e.printStackTrace();
            return SetStatus.setFunctionType(ReturnType.messageType_right.getType(), ReturnType.error.toString(), "补货单明细修改失败", e.getMessage(), "");
        }
    }
}
